package com.avcdata.aoscustommade.presenter;

import com.avcdata.aoscustommade.activity.CityDatail_Activity;
import com.avcdata.aoscustommade.bean.BaseResponseBean;
import com.avcdata.aoscustommade.bean.DateSelectCategoryBean;
import com.avcdata.aoscustommade.bean.DetailsBean;
import com.avcdata.aoscustommade.bean.HotBrandCumulativeBean;
import com.avcdata.aoscustommade.bean.TechnologyBean;
import com.avcdata.aoscustommade.main.BaseCallBack;
import com.avcdata.aoscustommade.model.CityDatailActivityModel;
import com.avcdata.aoscustommade.view.CityDatailActivityView;

import org.json.JSONObject;

/**
 * Created by zyh on 17/6/7.
 */

public class CityDatailActivityPresenter {
    private final CityDatailActivityView cityDatailActivityView;
    private final CityDatailActivityModel cityDatailActivityModel;

    public CityDatailActivityPresenter(CityDatailActivityView cityDatailActivityView, CityDatailActivityModel cityDatailActivityModel) {
        this.cityDatailActivityView = cityDatailActivityView;
        this.cityDatailActivityModel = cityDatailActivityModel;
    }

    //获取产品类型日期等
    public void loadSelectCategory(String type, int lastWeekCount) {
        cityDatailActivityModel.loadSelectCategory(type, lastWeekCount, new BaseCallBack() {
            @Override
            public void onSuccess(Object object) {
                cityDatailActivityView.loadSelectCategorySuccess((DateSelectCategoryBean) object);
            }

            @Override
            public void onFailure() {
                cityDatailActivityView.loadSelectCategoryFailure();
            }


            @Override
            public void onFailure(Throwable throwable) {
                cityDatailActivityView.loadSelectCategoryFailure(throwable);
            }
        });
    }

    //获取价格段＋容积＋渠道
    public void loadDatail(String categoryString, String userLimits, String lastWeek, String cityString, boolean isTabTime, int lastWeekCount, String time_startString, String time_endString, boolean accumulated) {
        cityDatailActivityModel.loadDatail(categoryString, userLimits, lastWeek, cityString, isTabTime, lastWeekCount, time_startString, time_endString, accumulated, new BaseCallBack() {
            @Override
            public void onSuccess(Object object) {
                cityDatailActivityView.loadDatailSuccess((JSONObject) object);
            }

            @Override
            public void onFailure() {
                cityDatailActivityView.loadDatailFailure();
            }


            @Override
            public void onFailure(Throwable throwable) {
                cityDatailActivityView.loadDatailFailure(throwable);
            }
        });
    }

    //获取热门品牌销售累计情况
    public void loadHotBrandSales(JSONObject jsonObject) {
        cityDatailActivityModel.loadHotBrandsales(jsonObject, new BaseCallBack() {
            @Override
            public void onSuccess(Object object) {
                cityDatailActivityView.loadHotBrandsalesSuccess((JSONObject) object);
            }

            @Override
            public void onFailure() {
                cityDatailActivityView.loadHotBrandsalesFailure();
            }


            @Override
            public void onFailure(Throwable throwable) {
                cityDatailActivityView.loadHotBrandsalesFailure(throwable);
            }
        });
    }

    //获取销售额占有率
    public void loadSalesOccupancy(JSONObject jsonObject) {
        cityDatailActivityModel.loadSalesOccupancy(jsonObject, new BaseCallBack() {

            @Override
            public void onSuccess(Object object) {
                cityDatailActivityView.loadSalesOccupancySuccess((HotBrandCumulativeBean) object);
            }

            @Override
            public void onFailure() {
                cityDatailActivityView.loadSalesOccupancyFailure();
            }


            @Override
            public void onFailure(Throwable throwable) {
                cityDatailActivityView.loadSalesOccupancyFailure(throwable);
            }
        });
    }

    //获取销售走势图
    public void loadSalesTrend(JSONObject object) {
        cityDatailActivityModel.loadSalesTrend(object, new BaseCallBack() {
            @Override
            public void onSuccess(Object object) {
                cityDatailActivityView.loadSalesTrendSuccess((JSONObject) object);
            }

            @Override
            public void onFailure() {
                cityDatailActivityView.loadSalesTrendFailure();
            }



            @Override
            public void onFailure(Throwable throwable) {
                cityDatailActivityView.loadSalesTrendFailure(throwable);
            }
        });
    }

    //获取top50机型技术类型
    public void loadTOP50Skilltype(String category, String type) {
        cityDatailActivityModel.loadTop50Skilltype(category, type, new BaseCallBack() {
            @Override
            public void onSuccess(Object object) {
                cityDatailActivityView.loadTop50SkilltypeSuccess((TechnologyBean) object);
            }

            @Override
            public void onFailure() {
                cityDatailActivityView.loadTop50SkilltypeFailure();
            }


            @Override
            public void onFailure(Throwable throwable) {
                cityDatailActivityView.loadTop50SkilltypeFailure(throwable);
            }
        });
    }

    //获取top50机型详情
    public void loadTOP50type(JSONObject jsonObject) {
        cityDatailActivityModel.loadTOP50type(jsonObject, new BaseCallBack() {
            @Override
            public void onSuccess(Object object) {
                cityDatailActivityView.loadTOP50typeSuccess((DetailsBean) object);
            }

            @Override
            public void onFailure() {
                cityDatailActivityView.loadTOP50typeFailure();
            }


            @Override
            public void onFailure(Throwable throwable) {
                cityDatailActivityView.loadTOP50typeFailure(throwable);
            }
        });
    }
}
